#coding=utf-8
import os, os.path, sys
homedir = os.path.expanduser('~')
google_base_path = os.path.join(homedir, 'google_appengine')

APP_ID = "gae_test"
db1 = './t.db'
db2 = './t2.db'

if not os.path.exists(google_base_path):
    raise EnvironmentError, 'google_appengine folders not found'

sys.path.append(google_base_path)
google_lib_path = os.path.join(google_base_path, 'lib')
sys.path.append(os.path.join(google_lib_path, 'webob'))
sys.path.append(os.path.join(google_lib_path, 'django'))

if len(sys.argv) > 1:
    APP_ID = sys.argv[1] 
os.environ['APPLICATION_ID'] = APP_ID

from google.appengine.api import apiproxy_stub_map
from google.appengine.api import datastore_file_stub
from google.appengine.api import mail_stub
from google.appengine.api import urlfetch_stub
from google.appengine.api import user_service_stub

# Start with a fresh api proxy.
apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()

# Use a fresh stub datastore.
stub = datastore_file_stub.DatastoreFileStub(APP_ID, db1, db2)
apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', stub)

from google.appengine.ext import db
from models import *
